/*
 * PKL 51 GUNUNG KIDUL
 * Subseksie DATA ENTRY + CAPI
 */

/*
 * PanelHome.java
 *
 * Created on Feb 5, 2012, 5:34:19 PM
 */
package pkl51.view;

import java.awt.CardLayout;
import pkl51.component.Label;
import pkl51.controller.ActionController;
import pkl51.controller.CardLayoutController;
import pkl51.controller.NavigationControl;
import pkl51.model.MahasiswaModel;
import pkl51.view.kuesioner.PanelBlok123;

/**
 *
 * @author Hindarwan
 */
public class PanelHome extends javax.swing.JPanel {

    private CardLayoutController cardNavigationController;
    
    public CardLayoutController getCardNavigationController() {
        return cardNavigationController;
    }

    private static PanelHome instance;
    
    public Label getLabelUserName() {
        return labelUserName;
    }
    
    public void setLabelUserName(String username) {
        labelUserName.setText(username);
    }

    /** Creates new form PanelHome */
    public PanelHome() {
        this.instance=this;
        initComponents();
        cardNavigationController = new CardLayoutController();
        cardNavigationController.setCardLayout((CardLayout) panelMenu.getLayout());
        cardNavigationController.setParentCard(panelMenu);
        
        NavigationControl.setCard(cardNavigationController);
        ActionController.setKuesioner(panelKuesioner);
    }

    public static PanelHome getInstance() {
        if(instance == null){
            instance = new PanelHome();
        }
        return instance;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panelNavigasi = new pkl51.component.PanelTransparan();
        logOutMenu = new pkl51.component.ButtonGloss();
        entryMenu = new pkl51.component.ButtonGloss();
        updateMenu = new pkl51.component.ButtonGloss();
        updateUser = new pkl51.component.ButtonGloss();
        homeMenu = new pkl51.component.ButtonGloss();
        panelUser = new pkl51.component.PanelTransparan();
        timeLabel1 = new pkl51.component.TimeLabel();
        waktu = new pkl51.component.LabelWaktu();
        panelMenu = new pkl51.component.PanelTransparan();
        panelHome = new pkl51.component.PanelTransparan();
        panelHead = new pkl51.component.PanelTransparan();
        labelStatus = new pkl51.component.Label();
        labelWelcome = new pkl51.component.Label();
        labelUserName = new pkl51.component.Label();
        panelTransparan1 = new pkl51.component.PanelTransparan();
        home1 = new pkl51.view.Home();
        panelKuesioner = new pkl51.view.PanelKuesioner();
        panelUpdate = new pkl51.view.PanelUpdate();
        userSetting = new pkl51.view.UserSetting();
        panelExport = new pkl51.view.PanelExport();

        setOpaque(false);
        setPreferredSize(new java.awt.Dimension(983, 546));

        panelNavigasi.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        logOutMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pkl51/image/logout.png"))); // NOI18N
        logOutMenu.setMnemonic('L');
        logOutMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logOutMenuActionPerformed(evt);
            }
        });

        entryMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pkl51/image/dataentry.png"))); // NOI18N
        entryMenu.setMnemonic('E');
        entryMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                entryMenuActionPerformed(evt);
            }
        });

        updateMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pkl51/image/dataupdate.png"))); // NOI18N
        updateMenu.setMnemonic('U');
        updateMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                updateMenuActionPerformed(evt);
            }
        });

        updateUser.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pkl51/image/usersetting.png"))); // NOI18N
        updateUser.setMnemonic('O');
        updateUser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                updateUserActionPerformed(evt);
            }
        });

        homeMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pkl51/image/home.png"))); // NOI18N
        homeMenu.setMnemonic('H');
        homeMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                homeMenuActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelNavigasiLayout = new javax.swing.GroupLayout(panelNavigasi);
        panelNavigasi.setLayout(panelNavigasiLayout);
        panelNavigasiLayout.setHorizontalGroup(
            panelNavigasiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelNavigasiLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelNavigasiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(updateUser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(logOutMenu, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(updateMenu, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(entryMenu, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(homeMenu, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        panelNavigasiLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {entryMenu, logOutMenu, updateMenu});

        panelNavigasiLayout.setVerticalGroup(
            panelNavigasiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelNavigasiLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(homeMenu, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(entryMenu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(updateMenu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(updateUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(logOutMenu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6))
        );

        panelUser.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, null, java.awt.Color.white, null, null));

        timeLabel1.setForeground(new java.awt.Color(255, 255, 255));
        timeLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        timeLabel1.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        timeLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        timeLabel1.setPattern("dd MMMM yyyy");

        waktu.setForeground(new java.awt.Color(255, 255, 255));
        waktu.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        waktu.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        waktu.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        javax.swing.GroupLayout panelUserLayout = new javax.swing.GroupLayout(panelUser);
        panelUser.setLayout(panelUserLayout);
        panelUserLayout.setHorizontalGroup(
            panelUserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(waktu, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(timeLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        panelUserLayout.setVerticalGroup(
            panelUserLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelUserLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(waktu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(timeLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        panelUserLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {timeLabel1, waktu});

        panelMenu.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        panelMenu.setLayout(new java.awt.CardLayout());

        panelHome.setBorder(null);

        panelHead.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        labelStatus.setForeground(new java.awt.Color(255, 255, 255));
        labelStatus.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelStatus.setText("HOME");
        labelStatus.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N

        labelWelcome.setForeground(new java.awt.Color(255, 255, 255));
        labelWelcome.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        labelWelcome.setText("Welcome  :");
        labelWelcome.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        labelWelcome.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        labelUserName.setForeground(new java.awt.Color(255, 255, 255));
        labelUserName.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        labelUserName.setText("Pengunjung");
        labelUserName.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
        labelUserName.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        javax.swing.GroupLayout panelHeadLayout = new javax.swing.GroupLayout(panelHead);
        panelHead.setLayout(panelHeadLayout);
        panelHeadLayout.setHorizontalGroup(
            panelHeadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelHeadLayout.createSequentialGroup()
                .addComponent(labelStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(labelWelcome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(labelUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        panelHeadLayout.setVerticalGroup(
            panelHeadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelHeadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(labelStatus, javax.swing.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE)
                .addComponent(labelUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(labelWelcome, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        panelTransparan1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        javax.swing.GroupLayout panelTransparan1Layout = new javax.swing.GroupLayout(panelTransparan1);
        panelTransparan1.setLayout(panelTransparan1Layout);
        panelTransparan1Layout.setHorizontalGroup(
            panelTransparan1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelTransparan1Layout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addComponent(home1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        panelTransparan1Layout.setVerticalGroup(
            panelTransparan1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelTransparan1Layout.createSequentialGroup()
                .addComponent(home1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(0, 0, 0))
        );

        javax.swing.GroupLayout panelHomeLayout = new javax.swing.GroupLayout(panelHome);
        panelHome.setLayout(panelHomeLayout);
        panelHomeLayout.setHorizontalGroup(
            panelHomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelHead, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(panelTransparan1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        panelHomeLayout.setVerticalGroup(
            panelHomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelHomeLayout.createSequentialGroup()
                .addComponent(panelHead, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(panelTransparan1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        panelMenu.add(panelHome, "cardHome");
        panelMenu.add(panelKuesioner, "cardKues");
        panelMenu.add(panelUpdate, "cardUpdate");
        panelMenu.add(userSetting, "cardUser");
        panelMenu.add(panelExport, "cardExport");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(panelUser, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panelNavigasi, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(panelMenu, javax.swing.GroupLayout.DEFAULT_SIZE, 747, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panelMenu, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(panelUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(panelNavigasi, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void entryMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_entryMenuActionPerformed
        // TODO add your handling code here:
        ActionController.setEntry(true);
        cardNavigationController.show("cardKues");
        PanelBlok123.getInstance().getTextFieldB1R2().requestFocusInWindow();
}//GEN-LAST:event_entryMenuActionPerformed

    private void updateMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateMenuActionPerformed
        // TODO add your handling code here:
        ActionController.setEntry(false);
        cardNavigationController.show("cardUpdate");
}//GEN-LAST:event_updateMenuActionPerformed

private void logOutMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logOutMenuActionPerformed
// TODO add your handling code here:
    FormUtama.getInstance().getCardControllerUtama().show("cardLogin");
    MahasiswaModel.getInstance().setNama("");
    MahasiswaModel.getInstance().setNim("");
    MahasiswaModel.getInstance().setPassword("");
//    Thread thread = new Thread(new BackupDB());
//    thread.start();
//    cardNavigationController.show("cardExport");
    
}//GEN-LAST:event_logOutMenuActionPerformed

    private void updateUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateUserActionPerformed
        // TODO add your handling code here:
        cardNavigationController.show("cardUser");
    }//GEN-LAST:event_updateUserActionPerformed

    private void homeMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_homeMenuActionPerformed
        // TODO add your handling code here:
        cardNavigationController.show("cardHome");
    }//GEN-LAST:event_homeMenuActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private pkl51.component.ButtonGloss entryMenu;
    private pkl51.view.Home home1;
    private pkl51.component.ButtonGloss homeMenu;
    private pkl51.component.Label labelStatus;
    private pkl51.component.Label labelUserName;
    private pkl51.component.Label labelWelcome;
    private pkl51.component.ButtonGloss logOutMenu;
    private pkl51.view.PanelExport panelExport;
    private pkl51.component.PanelTransparan panelHead;
    private pkl51.component.PanelTransparan panelHome;
    private pkl51.view.PanelKuesioner panelKuesioner;
    private pkl51.component.PanelTransparan panelMenu;
    private pkl51.component.PanelTransparan panelNavigasi;
    private pkl51.component.PanelTransparan panelTransparan1;
    private pkl51.view.PanelUpdate panelUpdate;
    private pkl51.component.PanelTransparan panelUser;
    private pkl51.component.TimeLabel timeLabel1;
    private pkl51.component.ButtonGloss updateMenu;
    private pkl51.component.ButtonGloss updateUser;
    private pkl51.view.UserSetting userSetting;
    private pkl51.component.LabelWaktu waktu;
    // End of variables declaration//GEN-END:variables
}
